From e0701e55d7a650596a60c8b060cb07bd8acc0204 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 9 Jan 2006 16:22:03 +0000 Subject: [PATCH] Don't emit time if we don't have time. Don't have time if gmtime fails. --- gpsbabel/xmlgeneric.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gpsbabel/xmlgeneric.c b/gpsbabel/xmlgeneric.c index d8895634e..578491d40 100644 --- a/gpsbabel/xmlgeneric.c +++ b/gpsbabel/xmlgeneric.c @@ -105,8 +105,10 @@ xml_fill_in_time(char *time_string, const time_t timep, int long_or_short) struct tm *tm = gmtime(&timep); char *format; - if (!tm) + if (!tm) { + *time_string = 0; return; + } if (long_or_short == XML_LONG_TIME) format = "%02d-%02d-%02dT%02d:%02d:%02dZ"; @@ -126,11 +128,13 @@ xml_write_time(FILE *ofd, const time_t timep, char *elname) { char time_string[64]; xml_fill_in_time(time_string, timep, XML_LONG_TIME); - fprintf(ofd, "<%s>%s\n", - elname, - time_string, - elname - ); + if (time_string) { + fprintf(ofd, "<%s>%s\n", + elname, + time_string, + elname + ); + } } -- 2.30.2